<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="format-detection" content="telephone=no">
    <title>详情</title>
    <link rel="stylesheet" href="/templates/default/css/frozen.css">
    <link rel="stylesheet" href="/templates/default/css/style.css"></head>
    <script src="/templates/default/js/lib/zepto.min.js"></script>
<body>

<footer class="ui-footer ui-footer-btn">
    <ul class="ui-tiled ui-border-t">
        <li>
            <div>
                <a href="/home/index/articleVote"><img src="/templates/default/images/btn2_01a.png" alt="评选投票"/></a>
            </div>
        </li>
        <li>
            <div>
                <a href="/home/index/vote_result"><img src="/templates/default/images/btn2_02.png" alt="投票记录"/></a>
            </div>
        </li>
    </ul>
</footer>
<section class="ui-container">
    <div class="head2">
        <img src="/templates/default/images/detail.png" alt="">
    </div>
    <div class="list01">
        <div class="item listhead">
            <div class="img"><img src="{{$smarty.const.WWW_URL}}{{$article_info.article_thumb}}" alt=""></div>
            <div class="h1"><span></span>{{$article_info.article_title}}</div>
            <div class="p">部门：{{$article_info.article_dept}}</div>
            <div class="btn"><a onclick="vote('{{$article_info.article_id}}',1,'img_id_{{$article_info.article_id}}')">
                <img id="img_id_{{$article_info.article_id}}" src="/templates/default/images/vote{{if $article_info.is_vote }}_cancel{{/if}}.png"></a></div>
        </div>

        <div class="line" style="overflow:hidden;"><img src="/templates/default/images/detail2.png" style="width:100%;float:left;" alt=""></div>
        {{foreach from=$article_type2_list item=i}}
        <div class="item person">
            <div class="pic"><img src="{{$smarty.const.WWW_URL}}{{$i.article_thumb}}" alt=""></div>
            <div class="h1">{{$i.article_title}}</div>
            <div class="p">性别：{{$i.article_sex}}&nbsp; &nbsp;角色：{{$i.article_role}}</div>
            <div class="vote"><a onclick="vote('{{$i.article_id}}',2,'img_id_{{$i.article_id}}')"><img id="img_id_{{$i.article_id}}" src="/templates/default/images/tou{{if $i.is_vote }}_cancel{{/if}}.png"></a></div>
        </div>
        {{/foreach}}

        <div class="item listend"></div>
    </div>
</section>

<script src="/templates/default/js/frozen.js"></script>
<div class="ui-dialog" style="background:none;" id="ui-dialog_1">
    <div class="ui-dialog-cnt" style="
				width: 30%;
				background: rgba(0, 0, 0, 0.7);
				color: #fff;
				border-radius: 5px;
				padding: 15px 20px;
				text-align: center;
				">

        投票成功！

    </div>
</div>

<div class="ui-dialog" id="ui-dialog_2">
    <div class="ui-dialog-cnt" style="width:90%; background:none;">

        <img src="/templates/default/images/more3.jpg" style="width:100%;display: none;" id="more3_error">
        <img src="/templates/default/images/repeat.jpg" style="width:100%;display: none;" id="repeat_error">

        <div class="ui-dialog-ft" style="
            position: absolute;
            top: 76%;
            color: rgba(0,0,0,0);
        ">
            <button type="button" data-role="button" style="color:rgba(0,0,0,0);" onclick="cancel('ui-dialog_2')">返回</button>
        </div>
    </div>
</div>

<script class="demo-script">
    $("#ui-dialog_1").click(function(){
        cancel('ui-dialog_1');
    })

    function vote(article_id,article_type,img_id){
        var url = '/home/index/vote';

        if($('#'+img_id).attr('src').indexOf('_cancel')>-1){//撤票
            url = '/home/index/cancelVote';
        }
        $.ajax({
            url: url,
            data: {
                article_id: article_id,
                article_type: article_type
            },
            type: 'POST',
            cache: false,
            dataType: 'html',
            success: function (data) {
                if(data==1){
                    if(url=='/home/index/vote'){
                        if(article_type==1){$('#'+img_id).attr('src','/templates/default/images/vote_cancel.png');}
                        else{$('#'+img_id).attr('src','/templates/default/images/tou_cancel.png');}

                        $("#ui-dialog_1").addClass("show");
                        setTimeout("cancel('ui-dialog_1')",2000)
                    }else{
                        if(article_type==1){$('#'+img_id).attr('src','/templates/default/images/vote.png');}
                        else{$('#'+img_id).attr('src','/templates/default/images/tou.png');}
                    }
                }else if(data==0){
                    alert('投票失败');
                }else if(data=='more3_error'){
                    $('#more3_error').css('display','block');
                    $('#repeat_error').css('display','none');
                    $("#ui-dialog_2").addClass("show");
                }
                else if(data=='repeat_error'){
                    $('#repeat_error').css('display','block');
                    $('#more3_error').css('display','none');
                    $("#ui-dialog_2").addClass("show");

                    if(article_type==1){$('#'+img_id).attr('src','/templates/default/images/vote_cancel.png');}
                    else{$('#'+img_id).attr('src','/templates/default/images/tou_cancel.png');}
                }
            },
            error: function () {
                //alert("AJAX异常！");
            }
        });
    }

    function cancel(dialog_id){
        $("#"+dialog_id).removeClass("show");
    }
</script>

</body>
</html>